﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SharepointSolutionInstaller.Utils.Configuration;

namespace SharepointSolutionInstaller.Views
{
    public partial class UpgradeView : InstallerControl
    {


        public UpgradeView()
        {

            InitializeComponent();

            messageLabel.Text = InstallConfiguration.FormatString(messageLabel.Text);

            string upgradeDescription = InstallConfiguration.UpgradeDescription;
            if (upgradeDescription != null)
            {
                upgradeDescriptionLabel.Text = upgradeDescription;
            }
            this.Title = Resources.CommonUIStrings.controlTitleUpgradeRemove;
            this.SubTitle = Resources.CommonUIStrings.controlSubTitleSelectOperation;
        }

        protected internal override void Open(InstallOptions options)
        {
            bool enable = upgradeRadioButton.Checked || removeRadioButton.Checked;
            Form.operation = InstallOperation.Upgrade;
            Form.btnNext.Enabled = enable;
        }

        protected internal override void Close(InstallOptions options)
        {
            Form.contentControls.Add(new InstallProcess());
        }

        private void upgradeRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (upgradeRadioButton.Checked)
            {
                Form.operation = InstallOperation.Upgrade;
                Form.btnNext.Enabled = true;
            }
        }

        private void removeRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (removeRadioButton.Checked)
            {
                Form.operation = InstallOperation.Uninstall;
                Form.btnNext.Enabled = true;
            }
        }
    }
}
